<template>
  <div class="container">
    <Nav />
    <div class="layout">
      <router-view class="view-content"></router-view>
    </div>
    <!-- <div>
      <el-table
        :data="state.userList"
        :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
        stripe
      >
        <el-table-column type="selection" width="55" />
        <el-table-column label="ID" prop="id" width="80" />
        <el-table-column label="账号" prop="username" width="200" />
        <el-table-column label="昵称" prop="nickname" width="200" />
        <el-table-column label="状态" prop="is_active" />
      </el-table>
    </div>
    <div class="pagination">
      <el-pagination
        :page-size="10"
        :total="state.total"
        background
        layout="prev, pager, next"
      ></el-pagination>
    </div> -->
  </div>
</template>

<script lang="ts">
import { defineComponent, reactive } from 'vue';
import { getUserList } from './api/service';
import Nav from './components/Nav.vue';

export default defineComponent({
  name: 'App',
  setup: function () {
    const state = reactive({
      userList: [],
      params: {
        page: 1,
        page_size: 10,
      },
      total: 0,
    });

    const handleSearch = async (): Promise<void> => {
      try {
        const data: any = await getUserList(state.params);
        state.userList = data.results;
        state.total = data.count;
      } catch (e) {
        console.error(e);
      }
    };
    handleSearch();
    return {
      state,
      handleSearch,
    };
  },
  components: {
    Nav,
  },
});
</script>

<style lang='less' scoped>
@import url("./less/index.less");

.pagination {
  text-align: right;
  margin-top: 12px;
}
body {
  background-color: #f9f9f9;
}

#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: left;
  padding-top: 50px;
}

.container {
  width: 1200px;
  margin: 0 auto;
}

img {
  vertical-align: bottom;
}

.layout {
  height: auto;
}

.button-container {
  display: flex;
  justify-content: space-between;
  flex: 1;
  margin-bottom: 24px;
}

.view-content {
  margin-top: 80px;
  background-color: #ffffff;
  padding: 12px 24px 24px 24px;
  border-radius: 8px;
}
</style>
